<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #red{
            width: 200px;height: 200px;background-color: red;
        }
        #green{
            width: 150px;height: 150px;background-color: green;
        }
        #blue{
            width: 100px;height: 100px;background-color: blue;
        }
    </style>
</head>
<body>
    <div id="red">
        <div id="green">
            <div id="blue">

            </div>
        </div>
    </div>
</body>
</html>
<script>
    var red=document.getElementById('red')
    var green=document.getElementById('green')
    var blue=document.getElementById('blue')
    red.addEventListener('click',(e)=>{e.stopPropagation();console.log("你单击了红色");})
    green.addEventListener('click',(e)=>{e.stopPropagation();console.log("你单击了绿色");})
    blue.addEventListener('click',(e)=>{
        e.stopPropagation()
        console.log("你单击了蓝色");})

</script>